﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Inovout.Cloud.DataStore.Models;

namespace Inovout.Cloud.DataStore.Services
{
    /// <summary>
    /// 表
    /// </summary>
    public interface ITableService
    {
        /// <summary>
        /// 创建表
        /// </summary>
        /// <param name="table">表的基本信息</param>
        /// <returns>表信息</returns>
        Table CreateTable(Table table);

        /// <summary>
        /// 删除表
        /// </summary>
        /// <param name="database">数据库</param>
        /// <param name="tableName">表名</param>
        /// <returns>是否操作成功</returns>
        bool DropTable(Database database, string tableName);

        /// <summary>
        /// 取得某个数据库下的某个表
        /// </summary>
        /// <param name="database">数据库</param>
        /// <param name="tableName">表名</param>
        /// <returns>表</returns>
        Table FindByName(Database database, string tableName);

        /// <summary>
        /// 取得某个数据库下的所有表信息
        /// </summary>
        /// <param name="database">数据库</param>
        /// <returns>所有表信息</returns>
        IEnumerable<Table> GetAllTables(Database database);

        /// <summary>
        /// 判断表是否存在
        /// </summary>
        /// <param name="database">数据库</param>
        /// <param name="tableName">表名</param>
        /// <returns>表是否存在</returns>
        bool TableExists(Database database, string tableName);

        /// <summary>
        /// 给表重命名
        /// </summary>
        /// <param name="database">数据库</param>
        /// <param name="oldTableName">表的原始名称</param>
        /// <param name="newTableName">表的新名称</param>
        /// <returns>是否操作成功</returns>
        bool ReNameTable(Database database, string oldTableName, string newTableName);

        /// <summary>
        /// 删除数据库的所有表
        /// </summary>
        /// <param name="database"></param>
        void DropAllTables(Database database);

    }
}
